package com.biscuit.page.basicservice.conf.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author biscuit
 * @createTime 2024/6/6 18:22
 */
@Slf4j
@Component
public class TableMetaObjectHandler implements MetaObjectHandler {

    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", LocalDateTime.now(), metaObject);
        this.setFieldValByName("lastUpdateTime", LocalDateTime.now(), metaObject);
    }

    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("lastUpdateTime", LocalDateTime.now(), metaObject);
    }

}
